package com.gj.demojuc.chap02;

import java.util.concurrent.locks.ReentrantLock;

/**
 * ReentrantLock实现可重入锁
 */
public class ReentrantLockDemo2 {
    private final ReentrantLock reentrantLock = new ReentrantLock();
    public void a(){
        reentrantLock.lock();
        this.b();
        System.out.println("a");
        reentrantLock.unlock();
    }
    public void b(){
        reentrantLock.lock();
        System.out.println("b");
        reentrantLock.unlock();
    }

    public static void main(String[] args) {
        new ReentrantLockDemo2().a();
    }

}
